import Long from "long";

export namespace collectionUtils {
    export function mergeMap<K, V>(m1: Map<K, V>, m2: Map<K, V>, valueMerge: (v1: V, v2: V) => V) {
        const rst = new Map<K, V>();
        m1.forEach((v, k) => {
            if (m2.has(k)) {
                rst.set(k, valueMerge(v, m2.get(k)!))
            } else {
                rst.set(k, v)
            }
        })
        m2.forEach((v, k) => {
            if (!m1.has(k)) rst.set(k, v)
        })
        return rst
    }
}